Grails : Tag - hasErrors
This page last changed on Feb 17, 2006 by [email protected].
Tag - hasErrorsDescriptionChecks whether a bean, request scope, or model reference has any errors and if it does invokes the body of the tag. Typically used in conjunction with either <g:eachError> or <g:renderErrors> Parameters
ExamplesChecks whether there are any errors for any bean throughout the request scope: <g:hasErrors> <g:eachError><p>${it.defaultMessage}</p></g:eachError> </g:hasErrors> Checks whether there are any errors for the specified bean <g:hasErrors bean="${book}"> <g:eachError><p>${it.defaultMessage}</p></g:eachError> </g:hasErrors> Checks whether there are any errors for the field "title" of the specified "book" bean: <g:hasErrors bean="${book}" field="title"> <div class="errors"> <g:renderErrors bean="${book}" field="title" as="list" /> </div> </g:hasErrors> As a method call in GSP only. In this case we check for a field error on a particular field and set a CSS class on the surround div thus allowing us to highlight the error with a red border for example: <div class="prop ${hasErrors(bean:user,field:'login', 'errors)}"> <label for="login"><input type="text" name="login" /> </div> |
![]() |
Document generated by Confluence on Mar 29, 2006 08:46 |